# encoding: utf-8

from fastui import AnyComponent
from fastui import components as c
from fastui.events import GoToEvent
    
    
def default_model(*components: AnyComponent, title: str | None = None) -> list[AnyComponent]:
    return [
        c.PageTitle(text=f'FastUI Demo — {title}' if title else 'FastUI Demo'),
        c.Navbar(
            title='FastUI Demo',
            title_event=GoToEvent(url='/'),
            start_links=[
                c.Link(
                    components=[c.Text(text='Navbar')],
                    on_click=GoToEvent(url='/Navbar'),
                    active='startswith:/Navbar',
                ),
                c.Link(
                    components=[c.Text(text='Tables')],
                    on_click=GoToEvent(url='/table/cities'),
                    active='startswith:/table',
                ),
            ],
        ),
        c.Page(
            components=[
                *((c.Heading(text=title),) if title else ()),
                *components,
            ],
        ),
        c.Footer(
            extra_text='FastUI Demo',
            links=[
                c.Link(
                    components=[c.Text(text='Footer')],
                    on_click=GoToEvent(url='/Footer'),
                    active='startswith:/Footer',
                ),
            ],
        ),
    ]